import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { NaiveUiResolver } from "unplugin-vue-components/resolvers";
import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
import path from "path";
import { viteExternalsPlugin } from 'vite-plugin-externals'
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    viteExternalsPlugin({
      t01Sip: 't01Sip'
    }),
    AutoImport({
      imports: [
        "vue",
        {
          "naive-ui": [
            "useDialog",
            "useMessage",
            "useNotification",
            "useLoadingBar",
          ],
        },
      ],
    }),

    Components({
      resolvers: [NaiveUiResolver()],
    }),
    createSvgIconsPlugin({
      // 指定需要缓存的图标文件夹
      iconDirs: [path.resolve(process.cwd(), "src/assets/icons")],
      // 指定symbolId格式
      symbolId: "icon-[dir]-[name]",

      /**
       * 自定义插入位置
       * @default: body-last
       */
      // inject?: 'body-last' | 'body-first'

      /**
       * custom dom id
       * @default: __svg__icons__dom__
       */
      // customDomId: '__svg__icons__dom__',
    }),
  ],
  base: "/ls/",
  // 配置文件引用别名 alias
  resolve: {
    alias: [
      {
        find: "@",
        replacement: path.resolve(__dirname, "./src"),
      },
    ],

  },
  server: {
    host: "0.0.0.0",
    port: 8000,
    proxy: {
      '/RcsProxy': {
        target: 'https://www.t01md.com.cn:15675',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/RcsProxy/, '')
      }
    }
  },
  css: {
    // preprocessorOptions: {
    //   scss: {
    //     additionalData:
    //       '@use "./node_modules/element-plus/theme-chalk/src/dark/css-vars.scss" as *;',
    //   },
    // },
  },
});
